$(function(){
	$(document).ajaxStop(function(){
		
	});	
	loadTableData();
	function loadTableData(isOnlyMatch){
		
		var param = {"icdType": "D"};
		if(isOnlyMatch) param.isOnlyMatch = isOnlyMatch;
		$.post(contextPath+"/ICD/getICDMatchResultTable.dhc", param).done(function(data){
			data = data.data;
			var columns = [
			               {
			            	   "data": "pindex",
			               },
			               {
			            	   "data": "icd",
			            	   "render": function(obj, type, full){
			            		   return ""+(full.ICDCODE?full.ICDCODE:"-")+"-"+(full.ICDDESC?full.ICDDESC:"-");
			            	   }
			               },
			               {
			            	   "data": "bjicd",
			            	   "render": function(obj, type, full){
			            		   return ""+(full.BJICDCODE?full.BJICDCODE:"-")+"-"+(full.BJICDDESC?full.BJICDDESC:"-");
			            	   }
			               },
			               {
			            	   "data": "TOTALCASECNT",
			               },
			               {
			            	   "data": "INCASECNT",
			               },
			               {
			            	   "data": "NOTINCASECNT",
			               },
			               ];
			var drawCallback=function(oSettings){
		    	//数据源中添加每一行序号
		    	var aoData = oSettings.aoData;
		    	var aiDisplay = oSettings.aiDisplay;
		    	for(var o in aiDisplay){
		    		var displayIndex = aiDisplay[o];
		    		aoData[displayIndex]._aData.pindex=Number(o)+1;
		    	}
		    	//将序号显示在表格中
		    	var o=oSettings._iDisplayStart;
	    		$("#icdMatchResult-table_d tbody").find("tr").each(function(i, n){
	    			$(n).find("td:eq(0)").html(i+o+1);
	    		})
		    }
			var paramsDataTables={lengthChange:false,scrollX:true,order:[[ 3, "desc" ]]};
			paramsDataTables.drawCallback=drawCallback;
			$("#icdMatchResult-table_d").dataTableBasic(columns,data,paramsDataTables);
			if(isOnlyMatch==1){
				$('#showUnvalidResult').iCheck('check');
			}else{
				$('#showUnvalidResult').iCheck('uncheck');
			}
			$("#showUnvalidResult").on('ifChanged',function(){
				if(this.checked){
					loadTableData(1);
				}else{
					loadTableData(0);
				}
			})
		});
	}
})